const express = require('express')
const categoryRouter= express.Router();

const DB = require('../DataConn/DB');

categoryRouter.use((req, res, next) => {
  //console.log(new Date(Date.now()), `请求路由/home及其子路由`);
  next();
})

//返回type数据
categoryRouter.get('/types',(req,res,next)=>{
  let list = DB.findDocuments('types',(result)=>{
    res.send(result)
  })
})
//返回指定表中的数据
categoryRouter.get('/goods',(req,res,next)=>{
  DB.findDocumentsLimit(String(req.query.type),Number(req.query.page*40),(result)=>{
    res.send(result);
  })
})
  
module.exports = categoryRouter;